#include "lem.h"

Lem::Lem(Level* level, std::string graphics)
{
	m_x = 0;
	m_y = 0;

	m_graphics = graphics;
	m_level = level;
	m_action = new ActionNone(this);
	m_next_action = nullptr;
}

Lem::~Lem()
{
	delete m_action;
	delete m_next_action;
}

void Lem::CheckActionChange()
{
	if (m_next_action != nullptr)
	{
		delete m_action;
		m_action = m_next_action;
		m_next_action = nullptr;
	}
}

void Lem::Spawn(float x, float y)
{
	m_x = x;
	m_y = y;

	// TODO: It should be a faller.
	SetNextAction(new ActionFall(this));
}

void Lem::SetNextAction(Action* action)
{
	m_next_action = action;
}

void Lem::Update(float timing_factor)
{
	CheckActionChange();
	m_action->Update(timing_factor);
}

void Lem::Draw()
{
	m_action->Draw();
}